<template>
	<view class="p-3 bg-white">
		<view class="flex j-sb a-center mb-3">
			<view class="font-bold">调拨清单</view>
			<!-- <view class="flex j-start a-center" v-if="listsData.length!=0">
				<view class="flex j-start a-center" @click="handleDelAll">
					<u-icon name="trash" color="#888" size="16"></u-icon>
					<view class="ml-1 text-secondary">全部清除</view>
				</view>
				<view class="flex j-start a-center ml-2" @click="navigateTo('pages/warehouse/outbound/export')">
					<u-icon name="arrow-downward" color="#00B0FF" size="16"></u-icon>
					<view class="ml-1 text-primary">导出清单</view>
				</view>
			</view> -->
		</view>

		<view v-if="listsData.length!=0">
			<view class="py-1 px-2 border rounded-10 mb-2" v-for="(item,index) in listsData" :key="index"
				@click="navigateTo('pages/warehouse/product/detail?productCode='+item.productCode)">
				<!-- <view class="flex j-start a-center my-2">
					<view class="text-right col-170">所在仓库：</view>
					<view class="flex-1">{{item.originaWarehouseName}}</view>
				</view> -->
				<view class="flex j-start a-center my-2">
					<view class="text-right col-170">商品编码：</view>
					<view class="flex-1">{{item.productCode}}</view>
					<image src="@/static/images/fuzhi.png" mode="widthFix" class="svgmini ml-3"
						@click.stop="utils.setClipboardData(item.productCode)"></image>
				</view>
				<view class="flex j-start a-center my-2">
					<view class="text-right col-170">手机型号：</view>
					<view class="flex-1">{{item.phoneModel}}</view>
				</view>
				<view class="flex j-start a-center my-2">
					<view class="text-right col-170">手机品牌：</view>
					<view class="flex-1">{{item.phoneBrand}}</view>
				</view>
				<view class="flex j-start a-center my-2">
					<view class="text-right col-170">内存：</view>
					<view>{{item.memory?item.memory:'--'}}</view>
				</view>
				<view class="flex j-start a-center my-2">
					<view class="text-right col-170">颜色：</view>
					<view class="flex-1">{{item.colour?item.colour:'--'}}</view>
				</view>
				<view class="flex j-start a-center my-2" >
					<view class="text-right col-170">IMEI：</view>
					<view class="flex-1">{{item.imei?item.imei:'--'}}</view>
				</view>
				<view class="flex j-start a-center my-2">
					<view class="text-right col-170">机况：</view>
					<view class="flex-1">{{item.subrackDesc?item.subrackDesc:'--'}}</view>
				</view>
				<view class="flex j-start a-center my-2">
					<view class="text-right col-170">调拨时间：</view>
					<view class="flex-1">{{parseTime(item.createTime)}}</view>
				</view>
				<u-gap height="1" bgColor="#eaeaea" marginTop="10rpx" marginBottom="10rpx"></u-gap>

				<view class="flex j-start a-center my-2">
					<view class="text-right col-170">调拨方：</view>
					<view class="flex-1">{{item.originaWarehouseName ?item.originaWarehouseName :'--'}}</view>
				</view>
				<view class="flex j-start a-center my-2">
					<view class="text-right col-170">调拨方仓库：</view>
					<view class="flex-1">{{item.originaUserName}}</view>
				</view>
				<view class="flex j-end a-center my-2">
					<view class="btn" @click.stop="handleAudit(item,'pass')">同意</view>
					<view class="btn-plain ml-3" @click.stop="handleAudit(item,'reject')">驳回</view>
				</view>
			</view>
		</view>
		<empty v-else />



	</view>
</template>

<script>
	import {
		allotAuditPageList,
		allotAudit
	} from '@/common/api/sales.js'
	export default {
		name: "",
		data() {
			return {

			}
		},
		onLoad(option) {
			this.searchList();
		},
		onPullDownRefresh() {
			this.searchList();
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 500);
		},
		onReachBottom() {
			if (!this.isLoadMore) {
				this.isLoadMore = true;
				this.query.pageNo += 1;
				this.getLists();
			}
		},
		watch: {},
		computed: {},
		methods: {
			getLists() {
				allotAuditPageList(this.query).then(res => {
					if (res.data && res.data.list.length == 0) {
						let oldLoad = {}
						this.isLoadMore = true;
						oldLoad = Object.assign({}, this.query);
						oldLoad.pageNo = this.query.pageNo;
						this.query = oldLoad
						this.$forceUpdate()
						return
					}

					this.isLoadMore = false;
					let oldList = this.listsData || []
					oldList.push(...res.data.list)
					this.listsData = oldList
				})
			},
			handleAudit(item, type) {
				let content;
				if (type == 'pass') {
					content = '确定要通过审核吗？'
				} else {
					content = '确定要驳回审核吗？'
				}
				uni.showModal({
					title: '提示',
					content: content,
					success: res => {
						if (res.confirm) {
							let aleUserId = this.app_user_info.id;
							allotAudit(aleUserId + '/' + item.id + '/' + type).then(res => {
								uni.$u.toast('操作成功');
								this.searchList()
							})
						} else if (res.cancel) {

						}
					}
				});
			},
		}
	}
</script>

<style lang="scss">
	.colorF {
		color: #4F4F4F;
	}
</style>